package com.ubaer.zsycz.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.lsw.Base.BaseHolder;
import com.lsw.Base.BaseSimpleAdapter;
import com.ubaer.zsycz.R;
import com.ubaer.zsycz.model.OrderModel;

/**
 * Created by Administrator on 2018/9/26 0026.
 */

public class AlreadyProcessedAdapter extends BaseSimpleAdapter<OrderModel> {
    public AlreadyProcessedAdapter(Context context) {
        super(context);
    }

    @Override
    protected BaseHolder<OrderModel> getHolder() {
        return new BaseHolder<OrderModel>() {
            View view;
            TextView tv_order_no;
            TextView tv_car_number;
            TextView tv_price;
            TextView tv_status;
            TextView tv_time;

            @Override
            public void bindViews(View parentView) {
                view = parentView.findViewById(R.id.view);
                tv_order_no = parentView.findViewById(R.id.tv_order_no);
                tv_car_number = parentView.findViewById(R.id.tv_car_number);
                tv_price = parentView.findViewById(R.id.tv_price);
                tv_status = parentView.findViewById(R.id.tv_status);
                tv_time = parentView.findViewById(R.id.tv_time);
            }

            @Override
            public void bindData(OrderModel item, int position) {
                if (position == 0) {
                    view.setVisibility(View.VISIBLE);
                } else {
                    view.setVisibility(View.GONE);
                }
                tv_order_no.setText(item.getOrder_no());
                tv_car_number.setText(item.getCard_num());
                tv_price.setText(item.getMoney());
                if (item.getStatus() == 1) {
                    tv_status.setText("充值成功");
                    tv_status.setTextColor(context.getResources().getColor(R.color.color_53913E));
                } else if (item.getStatus() == 2) {
                    tv_status.setText("充值失败");
                    tv_status.setTextColor(context.getResources().getColor(R.color.color_C73922));
                }
                tv_time.setText(item.getCreated_at());

            }
        };
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.item_already_processed;
    }
}
